package com.tensai.teach.beijing.utils;

import com.tensai.teach.beijing.BmapPoint;
import com.tensai.teach.beijing.model.old.base.second.features.geometry.JunctionGeo;

import java.util.List;
import java.util.OptionalDouble;

public class CommonUtils {
	public static BmapPoint getCenter(JunctionGeo junctionGeo) {
		List<BmapPoint> list = junctionGeo.makeBmapPointList();
		OptionalDouble lngOp = list.stream().mapToDouble(BmapPoint::getLng).average();
		OptionalDouble latOp = list.stream().mapToDouble(BmapPoint::getLat).average();
		OptionalDouble eleOp = list.stream().mapToDouble(BmapPoint::getEle).average();
		return new BmapPoint(lngOp.orElse(0), latOp.orElse(0), eleOp.orElse(0));
	}


}
